package jannex.query;

import jannex.mapping.ResultSetHandler;
import jannex.query.conditional.Predicate;
import jannex.sql.TypedPreparedStatement;

import java.util.HashMap;
import java.util.Map;

// TODO built-in batch support somehow
public class PlannedStatement<E> extends Clause<E> {

    protected final ResultSetHandler<E> handler;

    protected Map<Class<Clause<E>>, Clause<E>> clauseMap =
            new HashMap<>();

    public PlannedStatement(ResultSetHandler<E> handler) {
        super(null);
        this.handler = handler;
    }

    public PlannedStatement(Class<E> elementClass) {
        super(null);
        this.handler = null;
    }

    public PlannedStatement<E> pack(PlannedStatement<?> statement) {
        return this;
    }

    public PlannedStatement<E> raw(String sql) {
        return this;
    }

    public Where<E> where(E e) {
        return null;
    }

    public Where<E> where(Predicate... predicates) {
        return null;
    }

    <T extends Clause<E>> T getClause(Class<T> cls) {
        return (T) clauseMap.get(cls);
    }

    @Override
    public <S extends PlannedStatement> S clause(Clause<E> clause) {
        this.clauseMap.put((Class<Clause<E>>) clause.getClass(), clause);
        return (S) this;
    }

    @Override
    public void execute() {
    }

    @Override
    public TypedPreparedStatement<E> prepare() {
        return null;
    }

    Binding<E> binding() {
        return new Binding<E>(this);
    }
}
